//
//  CalculationElement.swift
//  BRCalculator
//
//  Created by 王亮 on 2018/11/27.
//  Copyright © 2018 王亮. All rights reserved.
//

import Foundation

public enum CalType {
    case directCal      //直接调用
    case inDirectCal    //间接调用
}

public protocol CalculationElement: BaseElement {
    
//    associatedtype ElementGenerator = () -> BaseElement
    
    var calType: CalType { get }

    func calculate(a : Double) -> (_ b: Double) -> Double
    func directCalculate(a : Double) -> Double
}

extension CalculationElement {
    func directCalculate(a : Double) -> Double {
        return a
    }
    
    func calculate(a : Double) -> (_ b: Double) -> Double {
        return {
            b in a + b
        }
    }
}
